home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20000824-20010305 / 000168_news@columbia.edu _Fri Dec 29 18:42:37 2000.msg < prev    next >
Internet Message Format  |  2020-01-01  |  3KB

  1. Return-Path: <news@columbia.edu>
  2. Received: from watsun.cc.columbia.edu (watsun.cc.columbia.edu [128.59.39.2])
  3.     by uhaligani.cc.columbia.edu (8.9.3/8.9.3) with ESMTP id SAA14707
  4.     for <kermit.misc@cpunix.cc.columbia.edu>; Fri, 29 Dec 2000 18:42:36 -0500 (EST)
  5. Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.59.30])
  6.     by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id SAA00425
  7.     for <kermit.misc@watsun.cc.columbia.edu>; Fri, 29 Dec 2000 18:42:36 -0500 (EST)
  8. Received: (from news@localhost)
  9.     by newsmaster.cc.columbia.edu (8.9.3/8.9.3) id SAA21602
  10.     for kermit.misc@watsun.cc.columbia.edu; Fri, 29 Dec 2000 18:31:26 -0500 (EST)
  11. X-Authentication-Warning: newsmaster.cc.columbia.edu: news set sender to <news> using -f
  12. From: Russ Allbery <rra@stanford.edu>
  13. Subject: Re: Converting struct tm to time_t
  14. Date: 29 Dec 2000 15:20:53 -0800
  15. Organization: The Eyrie
  16. Message-ID: <ylu27mq0fe.fsf@windlord.stanford.edu>
  17. To: kermit.misc@columbia.edu
  18.  
  19. In comp.unix.programmer, Frank da Cruz <fdc@watsun.cc.columbia.edu> writes:
  20. > Russ Allbery  <rra@stanford.edu> wrote:
  21.  
  22. >> Really?  I've never seen a Unix system without them, and was under the
  23. >> impression that they were introduced in the early 1980s.
  24.  
  25. > I don't mean you can't find them, but that using them in portable code
  26. > is often problematic -- which header files to include, where are they,
  27. > what are the argument types and where do you pick up their definitions,
  28. > etc.
  29.  
  30. True.  INN uses a header file called portable/time.h whose contents are:
  31.  
  32. /*  $Id: time.h,v 1.1 2000/10/03 01:27:13 rra Exp $
  33. **
  34. **  Portability wrapper around <time.h> and <sys/time.h>.
  35. **
  36. **  This header includes <time.h> and <sys/time.h> as applicable, handling
  37. **  systems where one can't include both headers (per the autoconf manual).
  38. */
  39.  
  40. #ifndef PORTABLE_TIME_H
  41. #define PORTABLE_TIME_H 1
  42.  
  43. #include "config.h"
  44.  
  45. #if TIME_WITH_SYS_TIME
  46. # include <sys/time.h>
  47. # include <time.h>
  48. #else
  49. # if HAVE_SYS_TIME_H
  50. #  include <sys/time.h>
  51. # else
  52. #  include <time.h>
  53. # endif
  54. #endif
  55.  
  56. #endif /* PORTABLE_TIME_H */
  57.  
  58. and just includes that instead of time.h or sys/time.h.  This requires
  59. that you be using autoconf and include:
  60.  
  61.     AC_HEADER_TIME
  62.     AC_CHECK_HEADERS(sys/time.h)
  63.  
  64. among your configure checks, though.
  65.  
  66. > Right, sorry, I meant mktime().  But again, just because some standard
  67. > requires certain behavior doesn't make it happen, especially when some
  68. > of the mktime() implementations precede the standard.
  69.  
  70. True, but I believe that the normalization function of mktime() was part
  71. of the original intent of the function.  It would really surprise me to
  72. find an implementation that doesn't do that.
  73.  
  74. -- 
  75. Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>